package com.xywl.escort.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xywl.escort.R;
import com.xywl.escort.bean.AddrBean;

import java.util.List;

public class ManageAddressAdapter extends BaseQuickAdapter<AddrBean, BaseViewHolder> {

    public ManageAddressAdapter(int layoutResId, @Nullable List<AddrBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AddrBean item) {
        helper.setText(R.id.tv_name, item.contacts);
        String address = item.province + item.city + item.district + item.address;
        helper.setText(R.id.tv_address, address);
        String contactNumber = item.contactNumber + "";
        helper.setText(R.id.tv_phone, contactNumber);

        ImageView imageCheck = helper.getView(R.id.image_check);
        if (item.isDefault == 1) {
            imageCheck.setImageResource(R.mipmap.bazaar_choose);
        } else {
            imageCheck.setImageResource(R.mipmap.bazaar_not_to_choose);
        }

        helper.addOnClickListener(R.id.layout_set_default);
        helper.addOnClickListener(R.id.tv_edit);
        helper.addOnClickListener(R.id.tv_delete);
    }
}